class Animal {
    public String name;
    public int age;
    public Animal(String name,int age) {
        this.name = name;
        this.age = age;
    }
    public void eat() {
        System.out.println(this.name+" 正在吃饭");
    }
}
class Dog extends Animal{
    public Dog(String name,int age) {
        super(name,age);
    }
    public void eat() {
        System.out.println(this.name + " 正在吃狗粮！");
    }

    @Override
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public void bark() {
        System.out.println(this.name + " 正在汪汪叫!");
    }
}

class Cat extends Animal {
    public Cat(String name,int age) {
        super(name,age);
    }
    public void miaomiao() {
        System.out.println(this.name + " 正在喵喵叫！");
    }
    public void eat() {
        System.out.println(this.name + " 正在吃猫粮！");
    }
}

public class Test {

    public static void eatFun(Animal animal) {
        animal.eat();
    }

    public static void main(String[] args) {
        Animal animal1 = new Dog("erha",2);
        Animal animal2 = new Cat("miao",1);
        animal1.eat();
        animal2.eat();
        eatFun(new Dog("gouzi",2));
        eatFun(new Cat("mao",1));
    }

    /*public static void func1(Animal animal) {
        animal.eat();
    }
    public static Animal func2() {
        return new Dog("da",1);
    }
    public static void main(String[] args){
        //Animal animal = new Animal("erha",2);
        Animal animal = new Dog("erha2",1);
        animal.eat();

        func1(new Dog("df",12));
        Dog dog = (Dog)func2();
        dog.bark();

        System.out.println(dog);

    }*/
}



